<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>
<title>申请书审核</title>
</head>
<body>
	<input type="hidden" id="childDiv" class="thickbox" />
		<form method="post" id="mainForm">
			<input type="hidden" id="prpCodes" name="prpCodes" value="" />
			<input type="hidden" id="type" name="type" value="" />
		</form>
	<br/>
<div class="soBox">
		<div class="detail ico_search">
			<table>
				<tr>
					<td rowspan="2"><strong>检索条件：</strong>
					</td>
					<td>
						<cpt:search key="prpApprove_search2"  repeatColumn="3" displayCount="5" leftStyle="width:100px"></cpt:search>
					</td>
					
				</tr>
				<tr>
				<td>
					<div class="clear_h10"></div>
					<input type='button' id='searchBt' class="button_an" value='查询' />
				</td>
				</tr>
			</table>
		</div>
	</div>
	<div class="clear_h10"></div>
	<div>
		<div id='TopBarMnt'></div>
		<table id='dataGrid'></table>
		<div id='dataBar'></div>
	</div>
	<script type="text/javascript">
		var irisGrid = new IrisGrid("dataGrid", "dataBar", 'TopBarMnt');
		var prcWin = new progressWin("${res}");//初始化遮罩层
		function showApproveDialog(type){
			var prpCodes="";
			
			$(":checkbox:checked").each(function(){
				var rowId=$(this).attr("id");
				var id=rowId.substring(rowId.lastIndexOf("_")+1,rowId.length);//取出grid中需要的id
				if(id!=null&&id!=""&&$.isNumeric(id))
					prpCodes=prpCodes+id+",";
			});
			
			if(prpCodes==""){
				scmError("请选择一条记录");
				return false;
			}
			if(type=="approve"){
					
					var prpnum = prpCodes.split(",").length-1;
					$("#prpCodes").val(prpCodes);
					$("#type").val(type);
					var options = {
							beforeSubmit : function() {
								prcWin.openWin();//打开遮罩层
								$("#approve").attr("disabled",true);
							}, // 表单提交前的回调函数
							success : function(msg) {
								prcWin.closeWin();
								scmSuccess(msg);
								irisGrid.getGridDom().jqGrid("refresh",0);//0是本页1是首页
								$("#approve").attr("disabled",false);
							},// 表单成功提交后的回调函数
							error : function() {
								scmError("操作失败,请联系系统管理员");
								prcWin.closeWin();
								$("#approve").attr("disabled",false);
							},
							url: "${ctx}/prpapprove/"+type
						};
					if(confirm("是否确认此"+prpnum+"份申请书?")){
						$("#mainForm").ajaxSubmit(options);
					}
					else{
						return;
					}
				
			}else{
				var url="${ctx}/prpapprove/openprpapprovedialog?prpCodes="+prpCodes+"&type="+type+"&TB_iframe=true&height=220&width=400";
				var title="申报审核意见（最多为500字）";
				showThickBox(url,title);	
			}
			
		}
		
	
		
		function closeDialog(){
			tb_remove();
		}
		function buildGrid() {			
			var columnAttrList = new Array();
			var columnAttr = new ColumnAttr("申请代码", "subject_code",	"subject_code", 4, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);		
			columnAttr = new ColumnAttr("项目名称", "zh_title","zh_title", 6, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("申请人姓名", "psn_name","psn_name", 4, "left", true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("资助类别", "grant_name","grant_name", 4, "left", true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("科学部编号", "prp_no","prp_no", 3, "left", true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("水印号", "prp_verson","prp_verson", 3, "left", true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("依托单位", "org_name","org_name", 3, "left", true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("提交时间", "submitDate", "submit_date", 3,"left", true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("状态", "statusName", "status", 5,"center", true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("文档状态", "doc_status", "doc_status", 3,"left", false);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("附件", "", "", 3,"center", false);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("status", "status", "status", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("flagCan", "flagCan", "flagCan", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			irisGrid.setColumnAttrs(columnAttrList);
			irisGrid.setToolsBar([ 
			{//工具栏建按钮
				id : 'approve',//按钮ID
				name : '确认',//按钮名称
				trigger : function(){//按钮onclick方法 grid本身 选中的行id 总行数
					showApproveDialog("approve");
				}
			}, 
			{
				id : 'return',
				name : '退回',
				trigger : function(){//按钮onclick方法
					showApproveDialog("return");
				}
			}
			]);
			irisGrid.setUrl("${ctx}/prpapprove/list-for-pdf?stat_year=${param.stat_year}");//查询url
			irisGrid.setCaption("暂写");
			irisGrid.setDefaultSortName("zh_title,prpseq");//默认排序字段
			irisGrid.setDefaultSortorder("asc");
			irisGrid.setWidth(978);//整个表格宽度
			irisGrid.setCheckAble(true);//表格左边是否要复选框
			irisGrid.setShowRowIndex(true);//是否显示行号
			irisGrid.setQueryBox('searchBt', 'prpApprove_search2');//查询条件 按钮名，查询条件function_key
			irisGrid.onSelectAll = function(selectid,isSelect){//全选事件
				
			}
			irisGrid.onSelectRow = function(selectid,isSelect){//选择事件	
				
			}
			
			irisGrid.build();
		}
		jQuery(function() {
			
			buildGrid();
	});
	/** 表格初始化**/
</script>
</body>
</html>